package com.bawei.property.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import com.bawei.property.databinding.ItemCarColorBinding
import com.bawei.property.entity.CarColorValue
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Author: Jason Zhang
 * Date: 2024/8/30
 * Desc: 汽车颜色数据适配器
 */
class CarColorAdapter constructor(private val layoutId: Int): BaseQuickAdapter<CarColorValue, CarColorAdapter.ItemViewHolder>(layoutId){

    inner class ItemViewHolder(val dataBinding: ItemCarColorBinding) : BaseViewHolder(dataBinding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
        var itemBinding = DataBindingUtil.inflate<ItemCarColorBinding>(LayoutInflater.from(parent.context), layoutId, parent, false)
        return ItemViewHolder(itemBinding)
    }

    override fun convert(holder: ItemViewHolder, item: CarColorValue) {
        holder.dataBinding.entity = item
        holder.dataBinding.executePendingBindings()
    }


}